/*
 * $Id: cosq.h,v 1.103.2.6 Broadcom SDK $
 * 
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 * 
 * DO NOT EDIT THIS FILE!
 * This file is auto-generated.
 * Edits to this file will be lost when it is regenerated.
 */

#ifndef __BCM_COSQ_H__
#define __BCM_COSQ_H__

#include <bcm/types.h>
#include <bcm/fabric.h>

#ifndef BCM_HIDE_DISPATCHABLE

/* Initialize the COSQ subsystem. */
extern int bcm_cosq_init(
    int unit);

/* De-initialize the COSQ subsystem. */
extern int bcm_cosq_detach(
    int unit);

/* Configure the number of Class of Service Queues (COSQs). */
extern int bcm_cosq_config_set(
    int unit, 
    int numq);

/* Configure the number of Class of Service Queues (COSQs). */
extern int bcm_cosq_config_get(
    int unit, 
    int *numq);

/* Set the mapping from internal priority to COS queue. */
extern int bcm_cosq_mapping_set(
    int unit, 
    bcm_cos_t priority, 
    bcm_cos_queue_t cosq);

/* Get the mapping from internal priority to COS queue. */
extern int bcm_cosq_mapping_get(
    int unit, 
    bcm_cos_t priority, 
    bcm_cos_queue_t *cosq);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Config parameters for Priority flow control */
typedef struct bcm_cosq_pfc_config_s {
    int xoff_threshold;     /* Assert backpressure when number of buffers used
                               is at or above this threshold. */
    int xon_threshold;      /* Remove backpressure when number of buffers used
                               drops below this threshold. */
    int xoff_threshold_bd;  /* Assert backpressure when number of buffer
                               descriptors used is at or above this threshold. */
    int xon_threshold_bd;   /* Remove backpressure when number of buffer
                               descriptors used drops below this threshold. */
    int drop_threshold;     /* Drop packets when number of buffers used hit this
                               threshold. */
    int reserved_buffers;   /* Number of buffers reserved for the specified
                               priority group. */
    int lossless;           /* lossless PFC enable for the specified priority
                               group. */
} bcm_cosq_pfc_config_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* Set the buffer pool allocation scheme for PFC (priority flow control). */
extern int bcm_cosq_pfc_config_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_pfc_config_t config, 
    int *pfc_id);

/* Get the buffer pool allocation scheme for PFC (priority flow control). */
extern int bcm_cosq_pfc_config_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_pfc_config_t *config, 
    int *pfc_id);

/* Set the mapping from internal priority to COS queue. */
extern int bcm_cosq_port_mapping_set(
    int unit, 
    bcm_port_t port, 
    bcm_cos_t priority, 
    bcm_cos_queue_t cosq);

/* Get the mapping from internal priority to COS queue. */
extern int bcm_cosq_port_mapping_get(
    int unit, 
    bcm_port_t port, 
    bcm_cos_t priority, 
    bcm_cos_queue_t *cosq);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Class of Service policies. */
#define BCM_COSQ_NONE                   0x0        /* Pass through. */
#define BCM_COSQ_STRICT                 0x01       /* Weights are ignored. */
#define BCM_COSQ_ROUND_ROBIN            0x02       /* Weights are ignored. */
#define BCM_COSQ_WEIGHTED_ROUND_ROBIN   0x03       
#define BCM_COSQ_WEIGHTED_FAIR_QUEUING  0x04       
#define BCM_COSQ_DEFICIT_ROUND_ROBIN    0x05       /* XGS3 only. */
#define BCM_COSQ_BOUNDED_DELAY          0x06       /* Strata only. */
#define BCM_COSQ_SP                     BCM_COSQ_STRICT /* Strict priority. */
#define BCM_COSQ_EF                     0x07       /* Expedited forwarding. */
#define BCM_COSQ_AF                     0x08       /* Assured forwarding. */
#define BCM_COSQ_SP_GLOBAL              0x09       
#define BCM_COSQ_BE                     0x0A       /* Best effort. */
#define BCM_COSQ_CALENDAR               0x0B       /* Calendar based scheduling
                                                      discipline. */
#define BCM_COSQ_SP0                    0x0C       /* Strict priority level 0. */
#define BCM_COSQ_SP1                    0x0D       /* Strict priority level 1. */
#define BCM_COSQ_SP2                    0x0E       /* Strict priority level 2. */
#define BCM_COSQ_SP3                    0x0F       /* Strict priority level 3. */
#define BCM_COSQ_SP4                    0x10       /* Strict priority level 4. */
#define BCM_COSQ_SP5                    0x11       /* Strict priority level 5. */
#define BCM_COSQ_SP6                    0x12       /* Strict priority level 6. */
#define BCM_COSQ_SP7                    0x13       /* Strict priority level 7. */
#define BCM_COSQ_AF0                    0x14       /* Assured forwarding level
                                                      0. */
#define BCM_COSQ_AF1                    0x15       /* Assured forwarding level
                                                      1. */
#define BCM_COSQ_AF2                    0x16       /* Assured forwarding level
                                                      2. */
#define BCM_COSQ_AF3                    0x17       /* Assured forwarding level
                                                      3. */
#define BCM_COSQ_AF4                    0x20       /* Assured forwarding level
                                                      4. */
#define BCM_COSQ_AF5                    0x21       /* Assured forwarding level
                                                      5. */
#define BCM_COSQ_AF6                    0x22       /* Assured forwarding level
                                                      6. */
#define BCM_COSQ_AF7                    0x23       /* Assured forwarding level
                                                      7. */
#define BCM_COSQ_GSP0                   0x18       /* Global Strict priority
                                                      level 0. */
#define BCM_COSQ_GSP1                   0x19       /* Global Strict priority
                                                      level 1. */
#define BCM_COSQ_GSP2                   0x1A       /* Global Strict priority
                                                      level 2. */
#define BCM_COSQ_GSP3                   0x1B       /* Global Strict priority
                                                      level 3. */
#define BCM_COSQ_GSP4                   0x1C       /* Global Strict priority
                                                      level 4. */
#define BCM_COSQ_GSP5                   0x1D       /* Global Strict priority
                                                      level 5. */
#define BCM_COSQ_GSP6                   0x1E       /* Global Strict priority
                                                      level 6. */
#define BCM_COSQ_GSP7                   0x1F       /* Global Strict priority
                                                      level 7. */
#define BCM_COSQ_MAX                    0x23       

#define BCM_COSQ_WEIGHT_UNLIMITED   -1         
#define BCM_COSQ_WEIGHT_STRICT      0          
#define BCM_COSQ_WEIGHT_MIN         1          

#define BCM_COSQ_PRIO_VALID(prio)  ((prio) >= 0 && (prio < 8)) 

#define BCM_COSQ_QUEUE_VALID(unit, numq)  \
    ((numq) >= 0 && (numq) < NUM_COS(unit)) 

#ifndef BCM_HIDE_DISPATCHABLE

/* Set Class of Service policy, weights and delay. */
extern int bcm_cosq_sched_set(
    int unit, 
    int mode, 
    const int weights[BCM_COS_COUNT], 
    int delay);

/* Set Class of Service policy, weights and delay. */
extern int bcm_cosq_port_sched_set(
    int unit, 
    bcm_pbmp_t pbm, 
    int mode, 
    const int weights[BCM_COS_COUNT], 
    int delay);

/* Set Class of Service policy, weights and delay. */
extern int bcm_cosq_sched_get(
    int unit, 
    int *mode, 
    int weights[BCM_COS_COUNT], 
    int *delay);

/* Get Class of Service policy, weights and delay. */
extern int bcm_cosq_port_sched_get(
    int unit, 
    bcm_pbmp_t pbm, 
    int *mode, 
    int weights[BCM_COS_COUNT], 
    int *delay);

/* Retrieve maximum weights for given COS policy. */
extern int bcm_cosq_sched_weight_max_get(
    int unit, 
    int mode, 
    int *weight_max);

#endif /* BCM_HIDE_DISPATCHABLE */

/* 
 * "Prioritize selected queue(s) for bandwidth before non-selected
 * queue(s).",
 */
#define BCM_COSQ_BW_EXCESS_PREF     0x00000001 
#define BCM_COSQ_BW_MINIMUM_PREF    0x00000002 
#define BCM_COSQ_BW_EAV_MODE        0x00000004 

#ifndef BCM_HIDE_DISPATCHABLE

/* Configure a port bandwidth distribution among COS queues. */
extern int bcm_cosq_port_bandwidth_set(
    int unit, 
    bcm_port_t port, 
    bcm_cos_queue_t cosq, 
    uint32 kbits_sec_min, 
    uint32 kbits_sec_max, 
    uint32 flags);

/* Configure a port bandwidth distribution among COS queues. */
extern int bcm_cosq_port_bandwidth_get(
    int unit, 
    bcm_port_t port, 
    bcm_cos_queue_t cosq, 
    uint32 *kbits_sec_min, 
    uint32 *kbits_sec_max, 
    uint32 *flags);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Discard (WRED) related flags. */
#define BCM_COSQ_DISCARD_ENABLE             0x0001     
#define BCM_COSQ_DISCARD_CAP_AVERAGE        0x0002     
#define BCM_COSQ_DISCARD_NONTCP             0x0004     
#define BCM_COSQ_DISCARD_COLOR_GREEN        0x0100     
#define BCM_COSQ_DISCARD_COLOR_YELLOW       0x0200     
#define BCM_COSQ_DISCARD_COLOR_RED          0x0400     
#define BCM_COSQ_DISCARD_COLOR_BLACK        0x0800     
#define BCM_COSQ_DISCARD_COLOR_ALL          0x0F00     
#define BCM_COSQ_DISCARD_DROP_FIRST         BCM_COSQ_DISCARD_COLOR_RED 
#define BCM_COSQ_DISCARD_PACKETS            0x1000     
#define BCM_COSQ_DISCARD_BYTES              0x2000     
#define BCM_COSQ_DISCARD_MARK_CONGESTION    0x4000     
#define BCM_COSQ_DISCARD_PORT               0x8000     
#define BCM_COSQ_DISCARD_DEVICE             0x10000    

#ifndef BCM_HIDE_DISPATCHABLE

/* Configure Weighted Random Early Discard (WRED). */
extern int bcm_cosq_discard_set(
    int unit, 
    uint32 flags);

/* Configure Weighted Random Early Discard (WRED). */
extern int bcm_cosq_discard_get(
    int unit, 
    uint32 *flags);

/* Configure a port's Weighted Random Early Discard (WRED) parameters. */
extern int bcm_cosq_discard_port_set(
    int unit, 
    bcm_port_t port, 
    bcm_cos_queue_t cosq, 
    uint32 color, 
    int drop_start, 
    int drop_slope, 
    int average_time);

/* Configure a port's Weighted Random Early Discard (WRED) parameters. */
extern int bcm_cosq_discard_port_get(
    int unit, 
    bcm_port_t port, 
    bcm_cos_queue_t cosq, 
    uint32 color, 
    int *drop_start, 
    int *drop_slope, 
    int *average_time);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Features that can be controlled on a gport/cosq  basis. */
typedef enum bcm_cosq_control_e {
    bcmCosqControlFabricConnectMinUtilization, /* percentage of minimum utilization
                                           before connection is established. */
    bcmCosqControlFabricConnectMaxTime, /* timeout configuration for minimum
                                           utilization connection setting. */
    bcmCosqControlBandwidthBurstMax,    /* kbits burst for maximum rate
                                           restriction if different from default
                                           burst size. */
    bcmCosqControlBandwidthBurstMin,    /* kbits burst for minimum rate
                                           guarantee if different from default
                                           burst size. */
    bcmCosqControlFabricConnectMax,     /* length a queue retains its fabric
                                           connection */
    bcmCosqControlPortTxqBackpressure,  /* the port capability of pausing
                                           traffic scheduling on the specific
                                           queue. */
    bcmCosqControlCopyPktToCpuUseTC,    /* use generic TC based COS mapping for
                                           copying packets to CPU. */
    bcmCosqControlWdrrGranularity,      /* granularity selector for WDRR weight. */
    bcmCosqControlDpValueDlf,           /* DP value of the unknown
                                           unicast/multicast packet. */
    bcmCosqControlDpChangeDlf,          /* DP change control for the unknown
                                           unicast/multicast packet. */
    bcmCosqControlDpChangeXoff,         /* DP change control for the
                                           flow-controllable port. */
    bcmCosqControlEavClassAWindow,      /* EAV Class A traffic credit carry-over
                                           control */
    bcmCosqControlEgressRateBurstAccumulateControl, /* Burst accumulate control for egress
                                           rate. */
    bcmCosqControlEgressRateType,       /* Rate type selector for egress rate
                                           control. */
    bcmCosqControlSchedulable,          /* Allow TX scheduling of packets in the
                                           queue. */
    bcmCosqControlEEETxQCongestionThreshold, /* If any of these thresholds are
                                           exceeded, EEE is disabled for all
                                           ports. */
    bcmCosqControlPacketLengthAdjust,   /* positive or negative queue packet
                                           length adjustment in bytes */
    bcmCosqControlCongestionManagedQueue, /* Congestion managed queue identifier */
    bcmCosqControlCongestionFeedbackWeight, /* Congestion feedback weight */
    bcmCosqControlCongestionSetPoint,   /* Congestion point queue size set point */
    bcmCosqControlCongestionSampleBytesMin, /* Minimum number of bytes to enqueue
                                           between congestion status sampling */
    bcmCosqControlCongestionSampleBytesMax, /* Maximum number of bytes to enqueue
                                           between congestion status sampling */
    bcmCosqControlFabricPortIngressScheduler, /* Associating ingress scheduler node
                                           with Fabric/Child gport */
    bcmCosqControlDropLimitAlpha,       /* Congestion drop limit alpha */
    bcmCosqControlDropLimitBytes,       /* Congestion drop limit bytes */
    bcmCosqControlResumeLimitBytes,     /* Resume traffic flow from Congestion
                                           drop */
    bcmCosqControlYellowDropLimitBytes, /* Congestion yellow drop limit bytes */
    bcmCosqControlRedDropLimitBytes,    /* Congestion red drop limit bytes */
    bcmCosqControlQselOffset,           /* associate qsel_offset_id */
    bcmCosqControlEgressFlowControlThreshold0, /* Boundary before which all traffic
                                           flows */
    bcmCosqControlEgressFlowControlThreshold1, /* Boundary for some traffic throttling */
    bcmCosqControlEgressFlowControlThreshold2, /* Boundary for higher traffic
                                           throttling */
    bcmCosqControlEgressFlowControlThreshold3, /* Boundary after which all traffic
                                           drops */
    bcmCosqControlFabricPortScheduler,  /* Associating scheduler node with
                                           Fabric/Child gport */
    bcmCosqControlClassMap,             /* Associate an Egress Cos to a specific
                                           resource */
    bcmCosqControlSchedulerAdoptAllPriority, /* Scheduler node priority adoption
                                           scheme, 1 - adopt all priorities, 0 -
                                           standard behaviour */
    bcmCosqControlEgressPool,           /* Associate an Egress Cos to a specific
                                           service pool */
    bcmCosqControlEgressPoolLimitBytes, /* Shared pool limit setting */
    bcmCosqControlEgressPoolYellowLimitBytes, /* Shared pool limit setting for yellow
                                           packets */
    bcmCosqControlEgressPoolRedLimitBytes, /* Shared pool limit setting for red
                                           packets */
    bcmCosqControlEgressPoolLimitEnable, /* Enable or disable using egress shared
                                           pool */
    bcmCosqControlEfPropagation,        /* Enable or disable EF propagation */
    bcmCosqControlFlowControlState      /* Set flow control state for the
                                           specified gport */
} bcm_cosq_control_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* set various features at the gport/cosq level. */
extern int bcm_cosq_control_set(
    int unit, 
    bcm_gport_t port, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_control_t type, 
    int arg);

/* Get various features at the gport/cosq level. */
extern int bcm_cosq_control_get(
    int unit, 
    bcm_gport_t port, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_control_t type, 
    int *arg);

#endif /* BCM_HIDE_DISPATCHABLE */

/* For Virtual output queues (system ports) */
typedef struct bcm_cosq_gport_discard_s {
    uint32 flags; 
    int min_thresh;         /* Queue depth in bytes to begin dropping. */
    int max_thresh;         /* Queue depth in bytes to drop all packets. */
    int drop_probability;   /* Drop probability at max threshold. */
    int gain;               /* Determines the smoothing that should be applied. */
    int ecn_thresh;         /* Queue depth in bytes to stop marking and start
                               dropping. */
} bcm_cosq_gport_discard_t;

/* For Virtual output queues (system ports) */
typedef enum bcm_cosq_gport_stats_e {
    bcmCosqGportGreenAcceptedPkts,      /* Green/DP0, accepted packet count. */
    bcmCosqGportGreenAcceptedBytes,     /* Green/DP0, accepted byte count. */
    bcmCosqGportGreenCongestionMarkedPkts, /* Green/DP0, ECN Marked packets. */
    bcmCosqGportGreenCongestionMarkedBytes, /* Green/DP0, ECN Marked bytes. */
    bcmCosqGportGreenDiscardDroppedPkts, /* Green/DP0, WRED dropped packets. */
    bcmCosqGportGreenDiscardDroppedBytes, /* Green/DP0, WRED dropped bytes. */
    bcmCosqGportYellowAcceptedPkts,     /* Yellow/DP1, accepted packet count. */
    bcmCosqGportYellowAcceptedBytes,    /* Yellow/DP1, accepted byte count. */
    bcmCosqGportYellowCongestionMarkedPkts, /* Yellow/DP1, ECN Marked packets. */
    bcmCosqGportYellowCongestionMarkedBytes, /* Yellow/DP1, ECN nMarked bytes. */
    bcmCosqGportYellowDiscardDroppedPkts, /* Yellow/DP1, WRED dropped packets. */
    bcmCosqGportYellowDiscardDroppedBytes, /* Yellow/DP1, WRED dropped bytes. */
    bcmCosqGportRedAcceptedPkts,        /* Red/DP2, accepted packet count. */
    bcmCosqGportRedAcceptedBytes,       /* Red/DP2, accepted byte count. */
    bcmCosqGportRedCongestionMarkedPkts, /* Red/DP2, ECN Marked packets. */
    bcmCosqGportRedCongestionMarkedBytes, /* Red/DP2, ECN Marked bytes. */
    bcmCosqGportRedDiscardDroppedPkts,  /* Red/DP2, WRED dropped packets. */
    bcmCosqGportRedDiscardDroppedBytes, /* Red/DP2, WRED dropped bytes. */
    bcmCosqGportBlackAcceptedPkts,      /* Black/DP3, accepted packet count. */
    bcmCosqGportBlackAcceptedBytes,     /* Black/DP3, accepted byte count. */
    bcmCosqGportNonWredDroppedPkts,     /* NON-WRED dropped packet count. */
    bcmCosqGportNonWredDroppedBytes,    /* NON-WRED dropped byte count. */
    bcmCosqGportDequeuedPkts,           /* dequeued packets. */
    bcmCosqGportDequeuedBytes,          /* dequeued bytes. */
    bcmCosqGportGreenDroppedPkts,       /* Green/DP0, non-WRED dropped pkts. */
    bcmCosqGportGreenDroppedBytes,      /* Green/DP0, non-WRED dropped bytes. */
    bcmCosqGportYellowDroppedPkts,      /* Yellow/DP1, non-WRED dropped pkts. */
    bcmCosqGportYellowDroppedBytes,     /* Yellow/DP1, non-WRED dropped bytes. */
    bcmCosqGportRedDroppedPkts,         /* Red/DP2, non-WRED dropped pkts. */
    bcmCosqGportRedDroppedBytes,        /* Red/DP2, non-WRED dropped bytes. */
    bcmCosqGportBlackCongestionMarkedPkts, /* Black/DP3, ECN Marked packets. */
    bcmCosqGportBlackCongestionMarkedBytes, /* Black/DP3, ECN Marked bytes. */
    bcmCosqGportBlackDiscardDroppedPkts, /* Black/DP3, WRED dropped at packets. */
    bcmCosqGportBlackDiscardDroppedBytes, /* Black/DP3, WRED dropped bytes. */
    bcmCosqGportBlackDroppedPkts,       /* Black/DP3, non-WRED dropped at
                                           packets. */
    bcmCosqGportBlackDroppedBytes,      /* Black/DP3, non-WRED dropped bytes. */
    bcmCosqGportOverSubscribeTotelDroppedPkts, /* Free list underflow, pkts dropped. */
    bcmCosqGportOverSubscribeTotalDroppedBytes, /* Free list underflow, bytes dropped. */
    bcmCosqGportOverSubscribeGuaranteeDroppedPkts, /* Gbl buf thres guarantee, pkts
                                           dropped. */
    bcmCosqGportOverSubscribeGuaranteedDroppedBytes, /* Gbl buf thres guarantee, bytes
                                           dropped. */
    bcmCosqGportOutLimitDroppedPkts,    /* Egress Admission Control (EAC)
                                           dropped pkts */
    bcmCosqGportOutLimitDroppedBytes,   /* EAC dropped bytes */
    bcmCosqGportOutLimitDroppedGreenPkts, /* EAC dropped green pkts */
    bcmCosqGportOutLimitDroppedGreenBytes, /* EAC dropped green bytes */
    bcmCosqGportOutLimitDroppedYellowPkts, /* EAC dropped yellow pkts */
    bcmCosqGportOutLimitDroppedYellowBytes, /* EAC dropped yellow bytes */
    bcmCosqGportOutLimitDroppedRedPkts, /* EAC dropped red pkts */
    bcmCosqGportOutLimitDroppedRedBytes, /* EAC dropped red bytes */
    bcmCosqGportOutLimitDroppedMulticastPkts, /* EAC dropped multicast pkts */
    bcmCosqGportOutLimitDroppedMulticastBytes, /* EAC dropped multicast bytes */
    bcmCosqGportOutPkts,                /* Egress Interface. */
    bcmCosqGportOutBytes,               /* Egress Interface. */
    bcmCosqGportReceivedBytes,          /* Bytes received into queue. */
    bcmCosqGportReceivedPkts,           /* Pkts received into queue. */
    bcmCosqGportDroppedBytes,           /* Bytes dropped in queue. */
    bcmCosqGportDroppedPkts,            /* Pkts dropped in queue. */
    bcmCosqGportDelayedBytes,           /* Delayed bytes. */
    bcmCosqGportDelayedHundredUs,       /* Maximum Pkts delay. */
    bcmCosqGportStatCount               /* Must be the last entry ! */
} bcm_cosq_gport_stats_t;

/* Profile stat event-related flags. */
#define BCM_COSQ_GPORT_STATS_SHARED 0x00000001 

/* Statistics Profile */
typedef struct bcm_cosq_gport_stat_profile_s {
    SHR_BITDCL stats[_SHR_BITDCLSIZE(bcmCosqGportOutBytes)]; /* Use Gport Stats Enumeration */
} bcm_cosq_gport_stat_profile_t;

#define BCM_COSQ_GPORT_STAT_PROFILE_INIT(_profile_set)  SHR_BITCLR_RANGE(_profile_set.stats, 0, (sizeof(_profile_set)*8)) 
#define BCM_COSQ_GPORT_STAT_PROFILE_ADD(_profile_set, _stat)  SHR_BITSET(_profile_set.stats, _stat) 
#define BCM_COSQ_GPORT_STAT_PROFILE_REMOVE(_profile_set, _stat)  SHR_BITCLR(_profile_set.stats, _stat) 
#define BCM_COSQ_GPORT_STAT_PROFILE_TEST(_profile_set, _stat)  SHR_BITGET(_profile_set.stats, _stat) 

/* Initialize a COSQ GPORT discard structure. */
extern void bcm_cosq_gport_discard_t_init(
    bcm_cosq_gport_discard_t *discard);

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t *physical_port, 
    int *num_cos_levels, 
    uint32 *flags);

#endif /* BCM_HIDE_DISPATCHABLE */

typedef int (*bcm_cosq_gport_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    int numq, 
    uint32 flags, 
    bcm_gport_t gport, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_traverse(
    int unit, 
    bcm_cosq_gport_traverse_cb cb, 
    void *user_data);

extern int bcm_cosq_fabric_distribution_add(
    int unit, 
    bcm_fabric_distribution_t ds_id, 
    int num_cos_levels, 
    uint32 flags, 
    bcm_gport_t *req_gport);

extern int bcm_cosq_fabric_distribution_get(
    int unit, 
    bcm_fabric_distribution_t ds_id, 
    int *num_cos_levels, 
    bcm_gport_t *req_gport, 
    uint32 *flags);

extern int bcm_cosq_gport_size_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 bytes_min, 
    uint32 bytes_max);

extern int bcm_cosq_gport_size_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 *bytes_min, 
    uint32 *bytes_max);

#endif /* BCM_HIDE_DISPATCHABLE */

#define BCM_COSQ_ALL            0x0001     

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_enable_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    int enable);

extern int bcm_cosq_gport_enable_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    int *enable);

extern int bcm_cosq_gport_stat_enable_set(
    int unit, 
    bcm_gport_t gport, 
    int enable);

extern int bcm_cosq_gport_stat_enable_get(
    int unit, 
    bcm_gport_t gport, 
    int *enable);

extern int bcm_cosq_gport_stat_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_gport_stats_t stat, 
    uint64 *value);

extern int bcm_cosq_gport_stat_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_gport_stats_t stat, 
    uint64 value);

extern int bcm_cosq_gport_stat_config_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_gport_stat_profile_t *profile);

extern int bcm_cosq_gport_stat_config_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_gport_stat_profile_t profile);

extern int bcm_cosq_gport_statistic_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_gport_stats_t stat, 
    uint64 *value);

extern int bcm_cosq_gport_statistic_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    uint32 flags, 
    bcm_cosq_gport_stats_t stat, 
    uint64 value);

extern int bcm_cosq_gport_statistic_multi_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    int stat_count, 
    bcm_cosq_gport_stats_t *stats_array, 
    int value_count, 
    uint64 *value_array);

extern int bcm_cosq_gport_statistic_multi_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_gport_t lgl_gport, 
    bcm_cos_queue_t cosq, 
    int stat_count, 
    bcm_cosq_gport_stats_t *stats_array, 
    uint64 value);

#endif /* BCM_HIDE_DISPATCHABLE */

#define BCM_COSQ_GPORT_WITH_ID              0x00000001 
#define BCM_COSQ_GPORT_SCHEDULER            0x00000002 
#define BCM_COSQ_GPORT_OVERLAY              0x00000004 
#define BCM_COSQ_GPORT_UCAST_QUEUE_GROUP    0x00000008 
#define BCM_COSQ_GPORT_DESTMOD_UCAST_QUEUE_GROUP 0x00000010 
#define BCM_COSQ_GPORT_MCAST_QUEUE          0x00000020 
#define BCM_COSQ_GPORT_MCAST_QUEUE_GROUP    0x00000040 
#define BCM_COSQ_GPORT_SUBSCRIBER           0x00000080 
#define BCM_COSQ_GPORT_EGRESS_GROUP         0x00000100 
#define BCM_COSQ_GPORT_DISABLE              0x00000200 /* Disable queue, used
                                                          for
                                                          BCM_COSQ_GPORT_CALENDAR
                                                          scheduling discipline */
#define BCM_COSQ_GPORT_CALENDAR             0x00000400 /* Indicates that this
                                                          gport is of scheduling
                                                          type CALENDAR */
#define BCM_COSQ_GPORT_QSEL_ENTRY_DISABLE   0x00000800 /* Inhibits automatic
                                                          update of queue
                                                          mapping table based
                                                          upon the GPORT
                                                          parameters */
#define BCM_COSQ_GPORT_WITH_SHAPING         0x00001000 
#define BCM_COSQ_GPORT_WITHOUT_SHAPING      0x00002000 
#define BCM_COSQ_GPORT_MULTIPATH            0x00004000 
#define BCM_COSQ_GPORT_VLAN_UCAST_QUEUE_GROUP 0x00008000 

#define BCM_COSQ_GPORT_LOCAL    BCM_COSQ_GPORT_SUBSCRIBER /* for compatibility */

#define BCM_COSQ_SUBSCRIBER_MAP_PORT_VLAN   0x00000001 
#define BCM_COSQ_SUBSCRIBER_MAP_ENCAP_ID    0x00000002 

typedef struct bcm_cosq_subscriber_map_s {
    uint32 flags; 
    bcm_port_t port; 
    bcm_vlan_t vlan; 
    bcm_if_t encap_id; 
    bcm_gport_t queue_id; 
} bcm_cosq_subscriber_map_t;

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_subscriber_map_add(
    int unit, 
    bcm_cosq_subscriber_map_t *map);

extern int bcm_cosq_subscriber_map_delete(
    int unit, 
    bcm_cosq_subscriber_map_t *map);

extern int bcm_cosq_subscriber_map_delete_all(
    int unit);

extern int bcm_cosq_subscriber_map_get(
    int unit, 
    bcm_cosq_subscriber_map_t *map);

#endif /* BCM_HIDE_DISPATCHABLE */

typedef int (*bcm_cosq_subscriber_map_traverse_cb)(
    int unit, 
    bcm_cosq_subscriber_map_t *map, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_subscriber_traverse(
    int unit, 
    bcm_cosq_subscriber_map_traverse_cb cb, 
    void *user_data);

extern int bcm_cosq_gport_add(
    int unit, 
    bcm_gport_t port, 
    int numq, 
    uint32 flags, 
    bcm_gport_t *gport);

extern int bcm_cosq_gport_delete(
    int unit, 
    bcm_gport_t gport);

/* Set the mapping from internal priority to COS queue. */
extern int bcm_cosq_gport_mapping_set(
    int unit, 
    bcm_port_t ing_port, 
    bcm_cos_t int_pri, 
    uint32 flags, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq);

/* Get the mapping from internal priority to COS queue. */
extern int bcm_cosq_gport_mapping_get(
    int unit, 
    bcm_port_t ing_port, 
    bcm_cos_t int_pri, 
    uint32 flags, 
    bcm_gport_t *gport, 
    bcm_cos_queue_t *cosq);

extern int bcm_cosq_gport_bandwidth_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 kbits_sec_min, 
    uint32 kbits_sec_max, 
    uint32 flags);

extern int bcm_cosq_gport_bandwidth_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    uint32 *kbits_sec_min, 
    uint32 *kbits_sec_max, 
    uint32 *flags);

extern int bcm_cosq_gport_sched_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    int mode, 
    int weight);

extern int bcm_cosq_gport_sched_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    int *mode, 
    int *weight);

extern int bcm_cosq_gport_discard_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_gport_discard_t *discard);

extern int bcm_cosq_gport_discard_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_gport_discard_t *discard);

#endif /* BCM_HIDE_DISPATCHABLE */

#define BCM_COSQ_SCHED_CONFIG_EXPEDITE  0x00000001 

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_sched_config_set(
    int unit, 
    bcm_gport_t gport, 
    int sched_mode, 
    int int_pri, 
    uint32 flags);

extern int bcm_cosq_gport_sched_config_get(
    int unit, 
    bcm_gport_t gport, 
    int sched_mode, 
    int int_pri, 
    uint32 *flags);

extern int bcm_cosq_gport_flow_control_set(
    int unit, 
    bcm_gport_t port, 
    bcm_cos_t int_pri, 
    uint32 flow_control_mask);

extern int bcm_cosq_gport_flow_control_get(
    int unit, 
    bcm_gport_t port, 
    bcm_cos_t int_pri, 
    uint32 *flow_control_mask);

extern int bcm_cosq_gport_attach(
    int unit, 
    bcm_gport_t sched_port, 
    bcm_gport_t input_port, 
    bcm_cos_queue_t cosq);

extern int bcm_cosq_gport_detach(
    int unit, 
    bcm_gport_t sched_port, 
    bcm_gport_t input_port, 
    bcm_cos_queue_t cosq);

extern int bcm_cosq_gport_attach_get(
    int unit, 
    bcm_gport_t sched_port, 
    bcm_gport_t *input_port, 
    bcm_cos_queue_t *cosq);

#endif /* BCM_HIDE_DISPATCHABLE */

#define BCM_COSQ_GPORT_QUEUE_ATTACH_WITH_ID 0x00000001 
#define BCM_COS_MULTICAST_EF                -2         
#define BCM_COS_MULTICAST_NON_EF            -3         

#define BCM_COSQ_GPORT_ATTACH_ID_SYSPORT_SET(_attach_id, _sysport)  \
    _SHR_COSQ_GPORT_ATTACH_ID_SYSPORT_SET(_attach_id,_sysport) 

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_queue_attach(
    int unit, 
    uint32 flags, 
    bcm_gport_t ingress_queue, 
    bcm_cos_t ingress_int_pri, 
    bcm_gport_t egress_queue, 
    bcm_cos_t egress_int_pri, 
    int *attach_id);

extern int bcm_cosq_gport_queue_detach(
    int unit, 
    bcm_gport_t ingress_queue, 
    bcm_cos_t ingress_int_pri, 
    int attach_id);

extern int bcm_cosq_gport_queue_attach_get(
    int unit, 
    bcm_gport_t ingress_queue, 
    bcm_cos_t ingress_int_pri, 
    bcm_gport_t *egress_queue, 
    bcm_cos_t *egress_int_pri, 
    int attach_id);

extern int bcm_cosq_gport_destmod_attach(
    int unit, 
    bcm_gport_t gport, 
    bcm_port_t ingress_port, 
    bcm_module_t dest_modid, 
    int fabric_egress_port);

extern int bcm_cosq_gport_destmod_detach(
    int unit, 
    bcm_gport_t gport, 
    bcm_port_t ingress_port, 
    bcm_module_t dest_modid, 
    int fabric_egress_port);

extern int bcm_cosq_gport_multipath_add(
    int unit, 
    bcm_gport_t multipath_gport, 
    bcm_gport_t member_gport, 
    bcm_cos_queue_t member_gport_cosq);

extern int bcm_cosq_gport_multipath_get(
    int unit, 
    bcm_gport_t multipath_gport, 
    int member_gport_max, 
    bcm_gport_t *member_gport_array, 
    bcm_cos_queue_t *member_gport_cosq_array, 
    int *member_gport_count);

extern int bcm_cosq_gport_multipath_delete(
    int unit, 
    bcm_gport_t multipath_gport, 
    bcm_gport_t member_gport, 
    bcm_cos_queue_t member_gport_cosq);

#endif /* BCM_HIDE_DISPATCHABLE */

/* For queue report thresholds on EPON */
typedef struct bcm_cosq_report_threshold_s {
    int threshold0; /* Queue report threshold0. */
    int threshold1; /* Queue report threshold1. */
    int threshold2; /* Queue report threshold2. */
    int threshold3; /* Queue report threshold3. */
} bcm_cosq_report_threshold_t;

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_gport_report_threshold_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_report_threshold_t *threshold);

extern int bcm_cosq_gport_report_threshold_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_report_threshold_t *threshold);

#endif /* BCM_HIDE_DISPATCHABLE */

/* XGS3 cosq counters */
typedef enum bcm_cosq_stat_e {
    bcmCosqStatDroppedPackets,          /* Dropped packet count. */
    bcmCosqStatDroppedBytes,            /* Dropped byte count. */
    bcmCosqStatYellowCongestionDroppedPackets, /* Dropped yellow packets due to
                                           congestion. */
    bcmCosqStatRedCongestionDroppedPackets, /* Dropped red packets due to
                                           congestion. */
    bcmCosqStatGreenDiscardDroppedPackets, /* WRED green packets. */
    bcmCosqStatYellowDiscardDroppedPackets, /* WRED yellow packets. */
    bcmCosqStatRedDiscardDroppedPackets, /* WRED red packets. */
    bcmCosqStatOutPackets,              /* Transmit packet count. */
    bcmCosqStatOutBytes                 /* Transmit byte count. */
} bcm_cosq_stat_t;

#ifndef BCM_HIDE_DISPATCHABLE

extern int bcm_cosq_stat_get(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_stat_t stat, 
    uint64 *value);

extern int bcm_cosq_stat_get32(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_stat_t stat, 
    uint32 *value);

extern int bcm_cosq_stat_set(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_stat_t stat, 
    uint64 value);

extern int bcm_cosq_stat_set32(
    int unit, 
    bcm_gport_t gport, 
    bcm_cos_queue_t cosq, 
    bcm_cosq_stat_t stat, 
    uint32 value);

#endif /* BCM_HIDE_DISPATCHABLE */

#endif /* __BCM_COSQ_H__ */
